package com.oitsm.mo.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * 检测器 类,定义了检测器相关的 ID、名称、监测参数、检测器状态属性
 * @author Arab Runner
 * Jun 19, 2011 4:11:28 PM
 */
@SuppressWarnings("serial")
@Entity
@Table(name="monitor")
public class Monitor implements Serializable {
	/**
	 * id
	 */
	@Id
	@Column(name="id")
	@GeneratedValue(strategy=GenerationType.AUTO,generator="")
	private Long id;
	/**
	 * 名称
	 */
	@Column(name="name")   
	private String name;
	
	/**
	 * 类型
	 */
	@Column(name="type") 
	private String type;
	
	/**
	 * 监测参数 - 手工维护这个字段 , 不使用 hibernate自动关联
	 */
	@javax.persistence.Transient
	private Map<String,String> props = new HashMap<String,String>();
	
	/**
	 * 状态
	 */
	@Embedded
	private Status status = new Status();
	
	/**
	 * 时间配置
	 */
	@Column(name="cron") 
	private String cron;
	
	/**
	 * 采集时间计划
	 */
	@javax.persistence.Transient
	private Schedule schedule = new Schedule();
	
	/**
	 * 队列时间
	 */
	@javax.persistence.Transient
	private long queuedTime = -1;
	
	public Monitor(){}
	
	public void addProp(String name,String value){
		props.put(name, value);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Map<String, String> getProps() {
		return props;
	}

	public void setProps(Map<String, String> props) {
		this.props = props;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Schedule getSchedule() {
		return schedule;
	}

	public void setSchedule(Schedule schedule) {
		this.schedule = schedule;
	}

	public long getQueuedTime() {
		return queuedTime;
	}

	public void setQueuedTime(long queuedTime) {
		this.queuedTime = queuedTime;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}
}
